package cn.moningxi.service.impl;

import cn.moningxi.bean.GoodsBusiness;
import cn.moningxi.mapper.GoodsBusinessMapper;
import cn.moningxi.service.GoodsBusinessService;
import cn.moningxi.util.CustomIdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class GoodsBusinessServiceImpl implements GoodsBusinessService {
    @Autowired
    GoodsBusinessMapper goodsBusinessMapper;

    @Override
    public GoodsBusiness queryById(Integer bid) {
        return goodsBusinessMapper.queryById(bid);
    }

    @Override
    public List<GoodsBusiness> queryAllBusiness() {
        return goodsBusinessMapper.queryAllBusiness();
    }

    @Override
    public GoodsBusiness selectByBusinessID(String BID) {
        return goodsBusinessMapper.selectByBusinessID(BID);
    }

    @Override
    public void updateBusniessInfo(GoodsBusiness goodsBusiness) {
        //String id = String.valueOf(new CustomIdGenerator().nextId(GoodsBusinessServiceImpl.class));
        goodsBusinessMapper.updateBusniessInfo(goodsBusiness);
    }

    @Override
    public GoodsBusiness queryBySn(String businessSn) {
        return goodsBusinessMapper.queryBySn(businessSn);
    }

    @Override
    public void addBusniess(GoodsBusiness goodsBusiness) {
        goodsBusiness.setBusinessId(String.valueOf(new CustomIdGenerator().nextId(GoodsBusinessServiceImpl.class)));
        goodsBusiness.setCreateTime(LocalDateTime.now());
        goodsBusinessMapper.addBusniess(goodsBusiness);
    }

}
